package com.pearl.web.demo.controller;

/**
 * @author TangDan
 * @version 1.0
 * @since 2023/3/20
 */
import java.util.Map;

import jakarta.servlet.http.HttpServletRequest;

import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

@Component
public class MyErrorViewResolver implements ErrorViewResolver {

    @Override
    public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
        if (status == HttpStatus.INSUFFICIENT_STORAGE) {
            new ModelAndView("myview");
        }
        return null;
    }
}

